﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace ACNetMusicClient
{
    public partial class MainScreen : Form
    {
        private ArrayList shareSongsList;

        public ArrayList ShareSongsList
        {
            get { return shareSongsList; }
            set { shareSongsList = value; }
        }
        private Controller ctrl;
        private SongController songsCtrl;
        
        public MainScreen()
        {
            InitializeComponent();
        }

        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ctrl.connect();
                MessageBox.Show("Connection successfully!");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Connection failure!", "Error");
            }
        }

        private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ctrl.disconnect();
                MessageBox.Show("Disconnection successfully!");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Disconnection failure!", "Error");
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void btnSearch_Click(object sender, EventArgs e)
        {

        }

        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (tabControl.SelectedIndex)
            {
                case 0 :
            	    break;
                case 1:
                    reloadShareSongsList();
                    break;
            }

        }

        private void reloadShareSongsList()
        {
            shareSongsList = songsCtrl.getSongsList();
            dgSharingSongs.DataSource = shareSongsList;
        }

        private void MainScreen_Load(object sender, EventArgs e)
        {
            ctrl = new Controller();
            songsCtrl = new SongController();
            comboBy.SelectedItem = "Name";
        }

        private void btnShare_Click(object sender, EventArgs e)
        {
            Sharing shareForm = new Sharing();
            shareForm.ShowDialog();
        }

        private void btnUnShare_Click(object sender, EventArgs e)
        {

        }

    }
}
